package com.chalk.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.dao.SportEventDao;
import com.chalk.model.SportEvent;
import com.chalk.service.SportEventService;
import com.chalk.service.VenueAndSeService;
import com.chalk.util.MpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-10
 */

@Service
public class SportEventServiceImpl extends ServiceImpl<SportEventDao, SportEvent> implements SportEventService {

    @Autowired
    VenueAndSeService venueAndSeService;
    @Autowired
    MpUtil<SportEvent> mpUtil;

    @Autowired
    SportEventDao sportEventDao;

    @Override
    public List<SportEvent> selectSportEventBySeId(Integer seId) {
        return sportEventDao.selectSportEventBySeId(seId);
    }

    @Override
    public List<SportEvent> getSportEvents(List<Integer> ids) {
        EntityWrapper<SportEvent> wrapper = mpUtil.getWrapper();
        wrapper.in("se_id", ids);
        List<SportEvent> sportEvents = selectList(wrapper);
        return ids.size() > 0 ? sportEvents : new ArrayList<SportEvent>();
    }

    @Override
    public List<SportEvent> getAllSportEvents() {
        EntityWrapper<SportEvent> wrapper = mpUtil.getWrapper();
        return selectList(wrapper);
    }
}
